package com.huawei.appmarket.service.usercenter.userinfo.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import androidx.annotation.Nullable;
import huawei.widget.HwTextView;
import o.azb;
import o.bsy;
import o.der.b;
import o.der.d;
import o.der.e;
import o.der.g;
import o.dof;
import o.eme;

public class UserInfoTextView extends LinearLayout {
    private boolean ʽ = false;
    private int ˊ;
    private ImageView ˋ;
    private HwTextView ˎ;
    private HwTextView ˏ;
    private Context ॱ;

    public UserInfoTextView(Context context) {
        super(context);
        ˊ(context);
    }

    public UserInfoTextView(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        ˊ(context);
    }

    public UserInfoTextView(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˊ(context);
    }

    private void ˊ(Context context) {
        this.ॱ = context;
        View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(g.ˑ, this);
        this.ˎ = (HwTextView) inflate.findViewById(d.ﹳॱ);
        this.ˋ = (ImageView) inflate.findViewById(d.ꜝ);
        this.ˏ = (HwTextView) inflate.findViewById(d.ᶥॱ);
    }

    public void setNickNameTextSize(float f) {
        this.ˎ.setTextSize(0, f);
    }

    public void setData(eme o_eme) {
        int i = 1;
        int i2 = 0;
        if (o_eme != null) {
            this.ˎ.setText(o_eme.ॱ());
            if (this.ʽ) {
                int i3;
                int dimensionPixelOffset;
                if (o_eme.ˊ()) {
                    this.ˋ.setVisibility(0);
                    this.ˋ.setImageResource(e.ˊᐝ);
                    i3 = 1;
                } else if (o_eme.ˋ()) {
                    this.ˋ.setVisibility(0);
                    this.ˋ.setImageResource(e.ˋˊ);
                    i3 = 1;
                } else {
                    this.ˋ.setVisibility(8);
                    i3 = 0;
                }
                if (i3 != 0) {
                    dimensionPixelOffset = this.ॱ.getResources().getDimensionPixelOffset(b.ʻॱ) + this.ॱ.getResources().getDimensionPixelOffset(b.ˊॱ);
                } else {
                    dimensionPixelOffset = 0;
                }
                if (dof.ॱ(o_eme.ˎ())) {
                    this.ˏ.setVisibility(8);
                    i = 0;
                } else {
                    this.ˏ.setVisibility(0);
                    this.ˏ.setText(o_eme.ˎ());
                }
                LayoutParams layoutParams = (LayoutParams) this.ˏ.getLayoutParams();
                if (i != 0) {
                    if (i3 != 0) {
                        layoutParams.leftMargin = this.ॱ.getResources().getDimensionPixelOffset(b.ॱˊ);
                    } else {
                        layoutParams.leftMargin = this.ॱ.getResources().getDimensionPixelOffset(b.ˊॱ);
                    }
                    i2 = layoutParams.leftMargin;
                }
                int ॱ = (ॱ() - dimensionPixelOffset) - i2;
                if (i != 0) {
                    ॱ /= 2;
                    dimensionPixelOffset = ˋ(this.ˎ, o_eme.ॱ(), ॱ);
                    this.ˎ.setMaxWidth(ˋ(this.ˏ, o_eme.ˎ(), ॱ) + ॱ);
                    this.ˏ.setMaxWidth(ॱ + dimensionPixelOffset);
                    return;
                }
                this.ˎ.setMaxWidth(ॱ);
            }
        }
    }

    private int ˋ(TextView textView, String str, int i) {
        int measureText = (int) textView.getPaint().measureText(str);
        if (measureText > i) {
            return 0;
        }
        return i - measureText;
    }

    public int ॱ() {
        if (this.ˊ <= 0) {
            this.ˊ = (azb.ॱ(this.ॱ) - (this.ॱ.getResources().getDimensionPixelOffset(bsy.e.ʿ) * 3)) - this.ॱ.getResources().getDimensionPixelOffset(bsy.e.ˎˎ);
        }
        return this.ˊ;
    }

    public void setContentWidth(int i) {
        this.ˊ = i;
    }

    public void setVisible(boolean z) {
        this.ʽ = z;
        if (z) {
            if (this.ˋ != null) {
                this.ˋ.setVisibility(0);
            }
            if (this.ˏ != null) {
                this.ˏ.setVisibility(0);
                return;
            }
            return;
        }
        if (this.ˋ != null) {
            this.ˋ.setVisibility(8);
        }
        if (this.ˏ != null) {
            this.ˏ.setVisibility(8);
        }
    }

    public void setNickName(int i) {
        if (this.ˎ != null) {
            this.ˎ.setText(i);
        }
    }

    public HwTextView ˎ() {
        return this.ˎ;
    }
}
